<?php

namespace SL\FrontBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class ProjetController extends Controller
{
	public function getProjetIndexAction()
	{
		$repository = $this->getDoctrine()->getManager()->getRepository('SLFrontBundle:Projet');
	
		$list1_projets = $repository->getAllProjets(1);
		$list2_projets = $repository->getAllProjets(2);
		$list3_projets = $repository->getAllProjets(3);
		
		return $this->render('SLFrontBundle:Projet:index.html.twig', array('list1_projets' => $list1_projets, 'list2_projets' => $list2_projets, 'list3_projets' => $list3_projets, 'template' => "projects", 'menu' => "projects", 'js' => "default"));
	}

	public function getProjetAction($url)
    {		
		$repository = $this->getDoctrine()->getManager()->getRepository('SLFrontBundle:Projet');
	
		$projet = $repository->getProjetWithImages($url);
		if ($projet === null)
		{
			throw $this->createNotFoundException('Projet: '.$url.' inexistant.');
		}
		
		$images = $projet->getImages();
		
        return $this->render('SLFrontBundle:Projet:projet.html.twig', array('projet' => $projet, 'images' => $images, 'template' => "project", 'menu' => "projects", 'js' => "project"));
    }
}
